import { ElMessageBox } from 'element-plus'

export interface MessageTipInfoType {
  tip: string
  message: string
  cancelText?: string
  confirmText?: string
  type?: 'success' | 'info' | 'warning' | 'error'
}

export const useMessageBox = (
  config: MessageTipInfoType = {
    tip: '提示!',
    message: 'proxy will permanently delete the file. Continue?',
    cancelText: '取消',
    confirmText: '确认',
    type: 'warning'
  },
  successCallback: () => void,
  errorCallback?: () => void
) => {
  ElMessageBox.confirm(config.message, config.tip, {
    confirmButtonText: config.confirmText,
    cancelButtonText: config.cancelText,
    type: config.type
  })
    .then(() => {
      successCallback && successCallback()
    })
    .catch(() => {
      errorCallback && errorCallback()
    })
}
